﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Common.Logging;
using ETL.DataAccess;
using ETL.Business.Models;

namespace ETL.Business.Handlers.ProjectManagementHelper
{
    public class GetAllProjectManagement
    {
        private ProjectManagementRepository prjMngRepository;
        public GetAllProjectManagement()
        {
            prjMngRepository = new ProjectManagementRepository();
        }

        public virtual IEnumerable<ProjectMangementModel> Execute()
        {
            IEnumerable<ProjectMangementModel> result = null;
            try
            {
                var allPrjMng = prjMngRepository.GetAllProjectManagement();
                if (allPrjMng != null && allPrjMng.Count() > 0)
                {
                    result = from s in allPrjMng select new ProjectMangementModel(s);
                }

                return result;
            }
            catch (Exception ex)
            {
                LogService.Service.Error(ex);
                return result;
            }
        }
    }
}
